#!/bin/sh -e

set -e

# ref: postinst in sudo package

case "$1" in
configure)

  echo "[*] Installed /opt/qrcode_detect"
  if [ ! -L /lib/systemd/system/qrcode_detect_server.service ]; then
    ln -s /opt/qrcode_detect/service/qrcode_detect_server.service /lib/systemd/system/qrcode_detect_server.service
    systemctl enable qrcode_detect_server
  fi

  if [ ! -L /usr/local/bin/qrcode_detect_server ]; then
    ln -s /opt/qrcode_detect/bin/qrcode_detect_server /usr/local/bin/qrcode_detect_server
    echo "[*] Installed /usr/local/bin/qrcode_detect_server"
  fi

  if [ ! -L /usr/local/bin/qrcode_detect_cli ]; then
    ln -s /opt/qrcode_detect/bin/qrcode_detect_cli /usr/local/bin/qrcode_detect_cli
    echo "[*] Installed /usr/local/bin/qrcode_detect_cli"
  fi

  ;;

esac